package com.springboot.merlin.controller;

import com.springboot.merlin.validator.DateTime;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Merlin
 * @Title: ValidatorController
 * @ProjectName springboot-learning
 * @Description: TODO
 * @date 2018/8/2814:48
 */
@RestController
//必须要在类上加这个注解，否则数据校验无法起作用
@Validated
public class ValidatorController {

    @GetMapping("test")
    public String validator(@DateTime(message = "日期格式错误!",format = "yyyy-MM-dd")String date){
        return date;
    }
}
